package com.palrevo.data.models;

import java.util.List;

/**
 * 
 * @author AAsha
 *
 */
public class MenuItem {
	
	private Long id;
	private Integer index;
	private Long pageId;
	private Boolean leaf;
	private String title;
	private List<MenuItem> menuItems;
	private Long parentId;
	
	public MenuItem() {
		super();
	}

	public MenuItem(Long id, Integer index, Long pageId, Boolean header,
			String title, List<MenuItem> menuItems) {
		super();
		this.id = id;
		this.index = index;
		this.pageId = pageId;
		this.leaf = header;
		this.title = title;
		this.menuItems = menuItems;
	}

	public MenuItem(MenuItem item) {
		super();
		this.id = item.id;
		this.index = item.index;
		this.pageId = item.pageId;
		this.leaf = item.leaf;
		this.title = item.title;
		this.menuItems = item.menuItems;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Integer getIndex() {
		return index;
	}

	public void setIndex(Integer index) {
		this.index = index;
	}

	public Long getPageId() {
		return pageId;
	}

	public void setPageId(Long pageId) {
		this.pageId = pageId;
	}
	
	public void setPageId(Object pageId) {
		if(pageId == null){
			this.pageId = null;
			return;
		}
		
		this.pageId = Long.valueOf(pageId.toString());
	}

	public Boolean getLeaf() {
		return leaf;
	}

	public void setLeaf(Boolean leaf) {
		this.leaf = leaf;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public List<MenuItem> getMenuItems() {
		return menuItems;
	}

	public void setMenuItems(List<MenuItem> menuItems) {
		this.menuItems = menuItems;
	}
	
	public Long getParentId() {
		return parentId;
	}

	public void setParentId(Long parentId) {
		this.parentId = parentId;
	}

	public void setParentId(Object parentId) {
		if(parentId == null){
			this.parentId = null;
			return;
		}
		
		this.parentId = Long.valueOf(parentId.toString());
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		MenuItem other = (MenuItem) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
}
